//
//  Controller09.swift
//  Swift30Days
//
//  Created by licheng ke on 2017/3/3.
//  Copyright © 2017年 licheng ke. All rights reserved.
//

import UIKit

//Image Scroller
class Controller09: UIViewController,UIScrollViewDelegate {

    let sv = UIScrollView();
    let imageView = UIImageView();
    
    override func viewDidLoad() {
        super.viewDidLoad()
        sv.frame = view.bounds;
        view.addSubview(sv);
        sv.backgroundColor = UIColor.gray.withAlphaComponent(0.7);
        
        let image = #imageLiteral(resourceName: "Steve");
        print("size: \(image.size)");
        imageView.image = #imageLiteral(resourceName: "Steve");
        imageView.frame = CGRect(origin: CGPoint(x: 0, y: 0), size: image.size);
        sv.addSubview(imageView);
        sv.contentSize = image.size;
        sv.maximumZoomScale = 3;
        sv.minimumZoomScale = 0.5;
        sv.delegate = self;
        sv.contentInset = UIEdgeInsetsMake(50, 10, 50, 10);
    }

    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imageView;
    }
    
    func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
        print("scale : \(scale)");
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }


}
